import {
	defineStore
} from 'pinia'
const useCityStore = defineStore('city', () => {
	const city = ref('');
	const getcity = async ()=> {
		const location = await getApp().getlocation();
		uni.$get({
			url: `https://api.map.baidu.com/geocoder?location=${location.lat},${location.lng}&output=json`,
			loading: false
		}).then(c => {
			console.log('地区获取成功')
			city.value = c.addressComponent.city
		}).catch(err => {
			console.log('地区获取失败')
			city.value = ''
			// uni.showModal({
			// 	title:'提示',
			// 	content:'地区获取失败，请稍后重试~',
			// 	showCancel:false
			// })
		})
	}
	return {
		city,
		getcity
	}
})
export default useCityStore;